package com.qf.service;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import com.qf.mapper.ZhangSanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

/**
 *
 * 张三转钱
 * @author lixu
 */
@Service
public class ZhangSanService {


    @Autowired
    private ZhangSanMapper zhangSanMapper;

    @Autowired
    private RestTemplate restTemplate;
    /**
     * 转钱
     */
    @Transactional
    @LcnTransaction  //分布式事务
    public void money() {
        //2:李四 加 500元
        restTemplate.getForObject("http://localhost:8081/ls/money", String.class);

        //1:张三 减 500元
        zhangSanMapper.money();

        int i = 1/0;

    }
}
